﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Forums : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            Console.WriteLine("post back");
        }
        else
        {
            Setup();
        }
    }

    private void Setup()
    {
        ForumList forumList = ForumList.GetForumListObject();
        List<Forum> forums = forumList.GetForums(Forum.FORUM_LIST_TABLE);

        LinkRepeater.DataSource = forums;
        LinkRepeater.DataBind();

        // GenerateLinksToForums(forums);
    }

    private void GenerateLinksToForums(List<Forum> forums)
    {
        string html = "<ul>";
        ListOfForums.InnerHtml = "";
        foreach (Forum forum in forums)
            html += string.Format("<li> {0} </li>", forum.ForumName);
        html += "</ul>";

        ListOfForums.InnerHtml = html;
    }
    protected void LinkRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "click")
        {
            Session["ForumName"] = e.CommandArgument.ToString();
            Response.Redirect("GeneralForum.aspx");
        }
    }

}